home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
lisp
/
kcl
/
abcl
/
abclr.lha
/
abclr
/
sys
/
object.abcl1
< prev
next >
Wrap
Lisp/Scheme
|
1988-11-26
|
4KB
|
128 lines
;;; -*- Mode: ABCL; Syntax: Common-lisp; Package: USER; Base: 10 -*-
;;;
;;; ABCL/R system Takuo Watanabe (Apr. 1988)
;;; Meta-Objects
(defvar *reifying-meta-obj-script-text*)
;;; generator of meta-objects
[object object-gen
(script
(=> [:new Vars Lex-Env Scripts]
(temporary [Me-ptr := [reifying-pointer-gen <== :new]]
raw-object)
[raw-object
:= [object object
(state [queue := '()]
[state := [state-gen <== [:new Vars Lex-Env]]]
[scriptset := Scripts]
[evaluator := [eval-gen <== :new]]
[mode := :dormant]
)
(script
(=> [:message Message Reply Sender]
[queue := (enqueue queue [Message Reply Sender])]
(if (eq mode :dormant)
(progn [mode := :active]
[Me-ptr <= :begin])))
(=> :begin
(let* ((mrs (first queue))
(scr (find-script (first mrs) scriptset)))
[queue := (dequeue queue)]
(if scr
[evaluator
<= [:do-prg (scr$body scr)
[env-gen
<== [:new (script-alist mrs scr)
state]]
Me-ptr]
@ (cont ignore
[Me-ptr <= :end])]
(progn
(warn "~S cannot handle the message ~S"
(name-of Me-ptr) (first mrs))
(if (second mrs)
[(second mrs) <= [:message nil nil Me-ptr]])
[Me-ptr <= :end]))))
(=> :end
(if (empty? queue)
[mode := :dormant]
[Me-ptr <= :begin]))
(=> :reified-meta
![object-gen
<== [:new (list (list 'queue queue)
(list 'state
[state <== :to-ABCLR])
(list 'scriptset scriptset)
(list 'evaluator
[evaluator <== :to-ABCLR])
(list 'mode mode))
global-env
*reifying-meta-obj-script-text*]])
)]]
[Me-ptr <== [:set-object raw-object]]
!Me-ptr)
)]
(eval-when (load eval)
(setq *reifying-meta-obj-script-text*
'((=> [:message Message Reply Sender]
[queue := (nconc queue (list [Message Reply Sender]))]
(if (eq mode :dormant) then
[mode := :active]
[Me <= :begin]))
(=> :begin
(temporary [object := Me] mrs scr newenv)
(if (null queue) then
(warn "~&Empty queue on ~S" (name-of [den Me])))
[mrs := (car queue)]
[queue := (cdr queue)]
[scr := (find-script (first mrs) scriptset)]
(if scr then
[newenv := [env-gen
<== [:new (script-alist mrs scr) state]]]
[evaluator <= [:do-prg (scr$body scr) newenv [den Me]] @
[cont ignore
[object <= :end]]]
else
(warn "~S cannot handle the message ~S"
(name-of [den Me]) (first mrs))
[(second mrs) <= nil]
[object <= :end]))
(=> :end
(if queue then
[Me <= :begin]
else
[mode := :dormant]))
(=> :queue
!queue)
(=> [:set-queue New-Queue]
![queue := New-Queue])
(=> :state
!state)
(=> [:set-state New-State]
![state := New-State])
(=> :scriptset
!scriptset)
(=> [:set-scriptset New-ScriptSet]
![scriptset := New-ScriptSet])
(=> [:script Message]
!(find-script Message scriptset))
(=> [:add-script New-Script]
(temporary [s := (digest New-Script)])
[scriptset := (add-script-list s scriptset)]
!s)
(=> [:delete-script Message] @ C
(temporary [script := (find-script Message scriptset)])
[scriptset := (delete script scriptset)]
!script)
(=> :evaluator
!evaluator)
(=> [:set-evaluator New-Evaluator]
![evaluator := New-Evaluator])
(=> :mode
!mode)
))
)